package com.lovejes.cuniao.dao.impl;

import java.util.Date;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.lovejes.cuniao.domain.CnFavor;
import com.lovejes.db.HibernateUtil;
import com.lovejes.exception.LoveJesException;

public class CnFavorDao extends CommonDao {
	
	Log logger = LogFactory.getLog(CnFavorDao.class);
	
	public String saveCnFavor(Map paraMap,Object bean) throws LoveJesException{
		CnFavor oCnFavor = (CnFavor)bean;
		Session s = null;
		Transaction tx = null;
		try {
			s = HibernateUtil.getSession();
			tx = s.beginTransaction();
			oCnFavor.setAddtime(new Date());
			insert(s, oCnFavor);
			tx.commit();
		} catch (HibernateException e) {
			logger.error(e);
			try {
				tx.rollback();
			} catch (HibernateException ex) {
				logger.error(ex);
			}
		} finally {
			HibernateUtil.closeSessionNoEx();
		}
		return oCnFavor.getId();
	}

}
